﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Base.Data.Migrations
{
    public partial class init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "t_department",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    code = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: true),
                    name = table.Column<string>(type: "character varying(60)", maxLength: 60, nullable: true),
                    enable_status = table.Column<int>(type: "integer", nullable: false),
                    remark = table.Column<string>(type: "character varying(600)", maxLength: 600, nullable: true),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false),
                    parent_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    is_leaf = table.Column<bool>(type: "boolean", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_department", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "t_member",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    code = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: true),
                    name = table.Column<string>(type: "character varying(60)", maxLength: 60, nullable: true),
                    password = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
                    phone = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: true),
                    user_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    enable_status = table.Column<int>(type: "integer", nullable: false),
                    remark = table.Column<string>(type: "character varying(600)", maxLength: 600, nullable: true),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_member", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "t_member_auth_role",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    member_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    role_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_member_auth_role", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "t_member_auth_role_group",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    member_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    role_group_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_member_auth_role_group", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "t_menu",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false),
                    parent_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    is_leaf = table.Column<bool>(type: "boolean", nullable: false),
                    label = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: true),
                    fcp_form_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    platform_type = table.Column<int>(type: "integer", nullable: false),
                    menu_param = table.Column<string>(type: "character varying(400)", maxLength: 400, nullable: true),
                    menu_icon = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
                    menu_style = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
                    num = table.Column<int>(type: "integer", nullable: false),
                    enable_status = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_menu", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "t_organization",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    code = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: true),
                    name = table.Column<string>(type: "character varying(60)", maxLength: 60, nullable: true),
                    api_url = table.Column<string>(type: "character varying(60)", maxLength: 60, nullable: true),
                    enable_status = table.Column<int>(type: "integer", nullable: false),
                    remark = table.Column<string>(type: "character varying(600)", maxLength: 600, nullable: true),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false),
                    parent_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    is_leaf = table.Column<bool>(type: "boolean", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_organization", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "t_role",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    code = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: true),
                    name = table.Column<string>(type: "character varying(60)", maxLength: 60, nullable: true),
                    platform_type = table.Column<int>(type: "integer", nullable: false),
                    role_type = table.Column<int>(type: "integer", nullable: false),
                    enable_status = table.Column<int>(type: "integer", nullable: false),
                    remark = table.Column<string>(type: "character varying(600)", maxLength: 600, nullable: true),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_role", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "t_role_auth_form",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    role_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    fcp_form_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_role_auth_form", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "t_role_auth_form_btn",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    role_auth_form_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    btn_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_role_auth_form_btn", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "t_role_auth_form_field",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    role_auth_form_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    field_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_role_auth_form_field", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "t_role_auth_info",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    role_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_role_auth_info", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "t_role_group",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    code = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: true),
                    name = table.Column<string>(type: "character varying(60)", maxLength: 60, nullable: true),
                    enable_status = table.Column<int>(type: "integer", nullable: false),
                    remark = table.Column<string>(type: "character varying(600)", maxLength: 600, nullable: true),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_role_group", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "t_role_group_auth_role",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    role_group_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    role_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_role_group_auth_role", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "t_user",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    code = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: true),
                    name = table.Column<string>(type: "character varying(60)", maxLength: 60, nullable: true),
                    enable_status = table.Column<int>(type: "integer", nullable: false),
                    remark = table.Column<string>(type: "character varying(600)", maxLength: 600, nullable: true),
                    dept_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_user", x => x.id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_t_department_code",
                table: "t_department",
                column: "code");

            migrationBuilder.CreateIndex(
                name: "IX_t_member_code",
                table: "t_member",
                column: "code");

            migrationBuilder.CreateIndex(
                name: "IX_t_organization_code",
                table: "t_organization",
                column: "code");

            migrationBuilder.CreateIndex(
                name: "IX_t_user_code",
                table: "t_user",
                column: "code");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "t_department");

            migrationBuilder.DropTable(
                name: "t_member");

            migrationBuilder.DropTable(
                name: "t_member_auth_role");

            migrationBuilder.DropTable(
                name: "t_member_auth_role_group");

            migrationBuilder.DropTable(
                name: "t_menu");

            migrationBuilder.DropTable(
                name: "t_organization");

            migrationBuilder.DropTable(
                name: "t_role");

            migrationBuilder.DropTable(
                name: "t_role_auth_form");

            migrationBuilder.DropTable(
                name: "t_role_auth_form_btn");

            migrationBuilder.DropTable(
                name: "t_role_auth_form_field");

            migrationBuilder.DropTable(
                name: "t_role_auth_info");

            migrationBuilder.DropTable(
                name: "t_role_group");

            migrationBuilder.DropTable(
                name: "t_role_group_auth_role");

            migrationBuilder.DropTable(
                name: "t_user");
        }
    }
}
